import request from '@/axios'
import type { DictData } from './types'

export const getListApi = (params: any) => {
  return request.get({ url: '/customer/customer', params })
}

export const getPublicListApi = (params: any) => {
  return request.get({ url: '/customer/customer/public', params })
}

export const saveDataApi = (data: Partial<DictData>): Promise<IResponse> => {
  if (data.id) {
    console.log('update')
    return request.put({ url: '/customer/customer/', data })
  } else {
    return request.post({ url: '/customer/customer/', data })
  }
}

export const getDictDataApi = (dictname: string): Promise<IResponse> => {
  return request.get({ url: '/datadict/cn', params: { dictname } })
}
